<template>
  <div class="content">
    <div class="search">
      Search Github Users <br>
      <input type="text" v-model="searchValue" placeholder="enter the name you search" @keydown.enter="axiosSearch">
      <button @click="axiosSearch">Search</button>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: 'MySearch',
  data() {
    return {
      searchValue: ''
    }
  },
  methods: {


    axiosSearch() {
      //请求前更新list数据
      this.$bus.$emit('upDatalistData', false, true, '', [])
      axios({
        method: 'GET',
        url: 'https://api.github.com/search/users',
        params: {
          q: this.searchValue
        },
      }).then(res => {
        this.$bus.$emit('upDatalistData', false, false, '', res.data.items)

      }, error => {
        this.$bus.$emit('upDatalistData', false, false, error.message, [])
      })
    }
  }


}
</script>

<style scoped>
.content {
  width: 780px;
  height: 200px;
  margin: 0 auto;
}

.search {
  color: white;
  position: relative;
  top: 80px;
  left: 30px;
}
</style>